#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[25], b[15], len;
int main(){
	cin >> n;
	for (int i = 0; i < 2 * n; i++) cin >> a[i];
	
	for (int i = 0; i < 2 * n; i++){
		for (int j = i + 1; j < 2 * n; j++){
			if (a[i] == a[j]) b[len++] = j - i + 1;
		}
	}
	sort(b, b + len);
	cout << b[len - 1] << endl;
	return 0;
}
